package m.base.model;

import m.common.model.FieldMeta;
import m.common.model.LinkTableMeta;
import m.common.model.Model;
import m.common.model.TableMeta;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.ModelUpdateUtil;
import m.system.cache.FlushCache;
import m.system.util.StringUtil;
import manage.model.ImageInfo;

import java.util.Date;

@TableMeta(name="tb_app_info",description="应用信息")
public class AppInfo extends Model implements FlushCache {
    @FieldMeta(name="register_code",type= FieldType.STRING,length=50,description="注册编码")
    private String registerCode;
    public static String toCodeNumber(String registerCode,String phone){
        return StringUtil.to32MD5("QMDNYS"+registerCode+phone);
    }
    @FieldMeta(name="register_title",type= FieldType.STRING,length=50,description="注册标题")
    private String registerTitle;
    @FieldMeta(name="register_description",type= FieldType.STRING,length=500,description="注册描述")
    private String registerDescription;
    @FieldMeta(name="register_alert",type= FieldType.STRING,length=500,description="注册提示")
    private String registerAlert;
    @LinkTableMeta(name="register_image_oid",table=ImageInfo.class,description="注册图片")
    private ImageInfo registerImage;
    @FieldMeta(name="level_title",type= FieldType.STRING,length=50,description="级别标题")
    private String levelTitle;
    @FieldMeta(name="level_description",type= FieldType.STRING,length=500,description="级别描述")
    private String levelDescription;
    @FieldMeta(name="level_alert",type= FieldType.STRING,length=500,description="级别提示")
    private String levelAlert;
    @LinkTableMeta(name="level_image_oid",table=ImageInfo.class,description="级别图片")
    private ImageInfo levelImage;
    @FieldMeta(name="offer_bottom1_txt",type= FieldType.STRING,length=100,description="报价单底部1")
    private String offerBottom1Txt;
    @FieldMeta(name="offer_bottom2_txt",type= FieldType.STRING,length=100,description="报价单底部2")
    private String offerBottom2Txt;
    @FieldMeta(name="offer_bottom2_link",type= FieldType.STRING,length=100,description="报价单底部2链接")
    private String offerBottom2Link;

    @FieldMeta(name="wx_app_id",type= FieldType.STRING,length=50,description="微信小程序appid")
    private String wxAppId;
    @FieldMeta(name="wx_secret",type= FieldType.STRING,length=50,description="微信小程序secret")
    private String wxSecret;
    //微信小程序
    @FieldMeta(name="wm_jsapi_ticket",type=FieldType.STRING,length=100,description="微信小程序wm_jsapi_ticket")
    private String wmJsapiTicket;
    @FieldMeta(name="wm_ticket_date",type=FieldType.DATE,description="微信小程序wm_ticket_时间")
    private Date wmTicketDate;
    @FieldMeta(name="wm_access_token",type=FieldType.STRING,length=600,description="微信小程序wm_access_token")
    private String wmAccessToken;
    @FieldMeta(name="wm_token_date",type=FieldType.DATE,description="微信小程序wm_token_时间")
    private Date wmTokenDate;

    public String getWmJsapiTicket() {
        return wmJsapiTicket;
    }

    public void setWmJsapiTicket(String wmJsapiTicket) {
        this.wmJsapiTicket = wmJsapiTicket;
    }

    public Date getWmTicketDate() {
        return wmTicketDate;
    }

    public void setWmTicketDate(Date wmTicketDate) {
        this.wmTicketDate = wmTicketDate;
    }

    public String getWmAccessToken() {
        return wmAccessToken;
    }

    public void setWmAccessToken(String wmAccessToken) {
        this.wmAccessToken = wmAccessToken;
    }

    public Date getWmTokenDate() {
        return wmTokenDate;
    }

    public void setWmTokenDate(Date wmTokenDate) {
        this.wmTokenDate = wmTokenDate;
    }

    public String getWxAppId() {
        return wxAppId;
    }

    public void setWxAppId(String wxAppId) {
        this.wxAppId = wxAppId;
    }

    public String getWxSecret() {
        return wxSecret;
    }

    public void setWxSecret(String wxSecret) {
        this.wxSecret = wxSecret;
    }

    public String getRegisterCode() {
        return registerCode;
    }

    public void setRegisterCode(String registerCode) {
        this.registerCode = registerCode;
    }

    public String getOfferBottom1Txt() {
        return offerBottom1Txt;
    }

    public void setOfferBottom1Txt(String offerBottom1Txt) {
        this.offerBottom1Txt = offerBottom1Txt;
    }

    public String getOfferBottom2Txt() {
        return offerBottom2Txt;
    }

    public void setOfferBottom2Txt(String offerBottom2Txt) {
        this.offerBottom2Txt = offerBottom2Txt;
    }

    public String getOfferBottom2Link() {
        return offerBottom2Link;
    }

    public void setOfferBottom2Link(String offerBottom2Link) {
        this.offerBottom2Link = offerBottom2Link;
    }

    public String getRegisterAlert() {
        return registerAlert;
    }

    public void setRegisterAlert(String registerAlert) {
        this.registerAlert = registerAlert;
    }

    public String getLevelTitle() {
        return levelTitle;
    }

    public void setLevelTitle(String levelTitle) {
        this.levelTitle = levelTitle;
    }

    public String getLevelDescription() {
        return levelDescription;
    }

    public void setLevelDescription(String levelDescription) {
        this.levelDescription = levelDescription;
    }

    public String getLevelAlert() {
        return levelAlert;
    }

    public void setLevelAlert(String levelAlert) {
        this.levelAlert = levelAlert;
    }

    public ImageInfo getLevelImage() {
        return levelImage;
    }

    public void setLevelImage(ImageInfo levelImage) {
        this.levelImage = levelImage;
    }

    public ImageInfo getRegisterImage() {
        return registerImage;
    }

    public void setRegisterImage(ImageInfo registerImage) {
        this.registerImage = registerImage;
    }

    public String getRegisterTitle() {
        return registerTitle;
    }

    public void setRegisterTitle(String registerTitle) {
        this.registerTitle = registerTitle;
    }

    public String getRegisterDescription() {
        return registerDescription;
    }

    public void setRegisterDescription(String registerDescription) {
        this.registerDescription = registerDescription;
    }

    @Override
    public AppInfo getCacheModel(String key) throws Exception {
        AppInfo model=ModelQueryList.getModel(AppInfo.class,"1","*","registerImage.*","levelImage.*");
        if(null==model){
            model=new AppInfo();
            model.setOid("1");
            ModelUpdateUtil.insertModel(model);
        }
        return model;
    }
}
